TeeChartPHP
[ class tree: TeeChartPHP ] [ index: TeeChartPHP ] [ all elements ]

Source for file Custom.php

Documentation is available at Custom.php

  1. <?php
  2.  
  3. /**
  4.  * Custom class
  5.  *
  6.  * Description: Base Series class inherited by a number of TeeChart
  7.  *
  8.  * @author
  9.  * @copyright (c) 1995-2008 by Steema Software SL. All Rights Reserved. <info@steema.com>
  10.  * @version 1.0
  11.  * @package TeeChartPHP
  12.  * @subpackage styles
  13.  * @link http://www.steema.com
  14.  */
  15.  
  16.   class Custom extends CustomPoint {
  17.  
  18.     protected $bAreaBrush;
  19.     protected $pAreaLines;
  20.     protected $bClickableLine = true;
  21.     protected $bDark3D = true;
  22.     protected $drawArea;
  23.     protected $drawLine = true;
  24.  
  25.     private $invertedStairs;
  26.     //private Color areaColor;
  27.     private $colorEachLine = true;
  28.     private $lineHeight;
  29.     private $outLine;
  30.     private $stairs;
  31.     private $bottomPos;
  32.     private $oldBottomPos;
  33.     private $oldX;
  34.     private $oldY;
  35.     private $oldColor;
  36.     private $tmpDark3DRatio;
  37.     private $tmpColor;
  38.     private $isLastValue;
  39.     protected $shadow;
  40.  
  41.  
  42.     // Interceptors
  43.     function __get( $property ) {
  44.       $method ="get{$property}";
  45.       if ( method_exists( $this, $method ) ) {
  46.         return $this->$method();
  47.       }
  48.     }
  49.  
  50.     function __set ( $property,$value ) {
  51.       $method ="set{$property}";
  52.       if ( method_exists( $this, $method ) ) {
  53.         return $this->$method($value);
  54.       }
  55.     }
  56.  
  57.     /**
  58.     * The class constructor.
  59.     */
  60.     public function Custom($c=null) {
  61.         parent::CustomPoint($c);
  62.         
  63.         $this->getLinePen()->setDefaultColor(new Color(0,0,0)); // Black
  64.         $this->shadow=new Shadow($c);
  65.     }
  66.  
  67.     protected function readResolve() {
  68.         $this->tmpColor = new Color(0,0,0,0,true);
  69.         $this->oldColor=$this->tmpColor; // ->EMPTY;
  70.         return parent::readResolve();
  71.     }
  72.  
  73.         /**
  74.           * Allows mouse clicks over the line drawn between points.<br>
  75.           * Default value: true
  76.           *
  77.           * <p>Example:
  78.           * <pre><font face="Courier" size="4">
  79.           * lineSeries.setClickableLine( false );
  80.           * </font></pre></p>
  81.           *
  82.           * @return boolean 
  83.           */
  84.     public function getClickableLine() {
  85.         return $this->bClickableLine;
  86.     }
  87.  
  88.     /**
  89.     * Allows mouse clicks over the line drawn between points.
  90.     * Default value: true
  91.     * @param boolean $value 
  92.     */
  93.  
  94.     public function setClickableLine($value) {
  95.         $this->bClickableLine = $this->setBooleanProperty($this->bClickableLine, $value);
  96.     }
  97.  
  98.     /**
  99.     * Opacity level from 0 to 100%
  100.     *
  101.     * @return integer 
  102.     */
  103.     public function getOpacity() {
  104.         return 100 - $this->getTransparency();
  105.     }
  106.  
  107.     /**
  108.     * Sets Opacity level from 0 to 100%
  109.     *
  110.     * @return integer 
  111.     */
  112.     public function setOpacity($value) {
  113.         $this->setTransparency(100 - $value);
  114.     }
  115.  
  116.     /**
  117.     * Transparency level from 0 to 100%
  118.     * Default value: 0
  119.     *
  120.     * @return integer 
  121.     */
  122.     public function getTransparency() {
  123.         return $this->getBrush()->getTransparency();
  124.     }
  125.  
  126.     /**
  127.     * Sets Transparency level from 0 to 100%
  128.     * Default value: 0
  129.     * <p>Example:<pre><font face="Courier" size="4">
  130.     * Series1.setTransparency(45);
  131.     * </font></pre></p>
  132.     *
  133.     * @param integer $value 
  134.     */
  135.     public function setTransparency($value) {
  136.         $this->getBrush()->setTransparency($value);
  137.     }
  138.  
  139.     /**
  140.     * Sets Brush characteristics.
  141.     *
  142.     * @return object {@link ChartBrush}
  143.     */
  144.     public function getBrush() {
  145.         return $this->bBrush;
  146.     }
  147.  
  148.     /**
  149.     * Darkens parts of 3D Line Series to add depth.<br>
  150.     * Default value: true
  151.     *
  152.     * @return boolean 
  153.     */
  154.     public function getDark3D() {
  155.         return $this->bDark3D;
  156.     }
  157.  
  158.     /**
  159.     * Darkens parts of 3D Line Series to add depth.<br>
  160.     * Default value: true
  161.     *
  162.     * @param boolean $value 
  163.     */
  164.     public function setDark3D($value) {
  165.         $this->bDark3D = $this->setBooleanProperty($this->bDark3D, $value);
  166.     }
  167.  
  168.     public function setChart($c) {
  169.         parent::setChart($c);
  170.         if ($this->bAreaBrush != null) {
  171.             $this->bAreaBrush->setChart($c);
  172.         }
  173.         if ($this->pAreaLines != null) {
  174.             $this->pAreaLines->setChart($c);
  175.         }
  176.         if ($this->outLine != null) {
  177.             $this->outLine->setChart($c);
  178.         }
  179.     }
  180.  
  181.     public function setColor($value) {
  182.         parent::setColor($value);
  183.         if ($this->bAreaBrush != null) {
  184.             $this->bAreaBrush->setColor($value);
  185.         }
  186.     }
  187.  
  188.         /**
  189.           * Steps line joining adjacent points.<br>
  190.           * In most normal situations, a series draws a line between each Line
  191.           * point. This makes the Line appear as a "mountain" shape. However,
  192.           * setting Stairs to true will make the Series draw 2 Lines between each
  193.           * pair of points, thus giving a "stair" appearance.<br>
  194.           * This is most used in some financial Chart representations. <br>
  195.           * When Stairs is set to true you may set InvertedStairs to true to alter
  196.           * the direction of the step. <br>
  197.           * Default value: false
  198.           *
  199.           * @return boolean 
  200.           */
  201.     public function getStairs() {
  202.         return $this->stairs;
  203.     }
  204.  
  205.         /**
  206.           * Steps line joining adjacent points.<br>
  207.           * Default value: false
  208.           *
  209.           * <p>Example:
  210.           * <pre><font face="Courier" size="4">
  211.           * areaSeries1.setStairs(true);
  212.           * areaSeries2.setStairs(true);
  213.           * </font></pre></p>
  214.           *
  215.           * @see #getStairs
  216.           * @param value boolean
  217.           */
  218.     public function setStairs($value) {
  219.         $this->stairs = $this->setBooleanProperty($this->stairs, $value);
  220.     }
  221.  
  222.         /**
  223.           * Enables/Disables the coloring of each connecting line of a series.<br>
  224.           * Default value: true
  225.           *
  226.           * <p>Example:
  227.           * <pre><font face="Courier" size="4">
  228.           * lineSeries.setColorEach(true); lineSeries.setColorEachLine(false);
  229.           * </font></pre></p>
  230.           *
  231.           * @return boolean 
  232.           */
  233.     public function getColorEachLine() {
  234.         return $this->colorEachLine;
  235.     }
  236.  
  237.         /**
  238.           * Enables/Disables the coloring of each connecting line of a series.<br>
  239.           * Default value: true
  240.           *
  241.           * @param value boolean
  242.           */
  243.     public function setColorEachLine($value) {
  244.         $this->colorEachLine = $this->setBooleanProperty($this->colorEachLine, $value);
  245.     }
  246.  
  247.         /**
  248.           * Changes the direction of the step, when true.<br>
  249.           * Default value: false
  250.           *
  251.           * @return boolean 
  252.           */
  253.     public function getInvertedStairs() {
  254.         return $this->invertedStairs;
  255.     }
  256.  
  257.         /**
  258.           * Changes the direction of the step, when true.<br>
  259.           * Default value: false
  260.           *
  261.           * @param value boolean
  262.           */
  263.     public function setInvertedStairs($value) {
  264.         $this->invertedStairs = $this->setBooleanProperty($this->invertedStairs, $value);
  265.     }
  266.  
  267.  
  268.         /**
  269.           * Pen for Series Line's outer pen.<br>
  270.           * Default value: null
  271.           *
  272.           * <p>Example:
  273.           * <pre><font face="Courier" size="4">
  274.           * lineSeries.getOutline().setColor(Color.Yellow);
  275.           * </font></pre></p>
  276.           *
  277.           * @return ChartPen 
  278.           */
  279.     public function getOutLine() {
  280.         if ($this->outLine == null) {
  281.             $this->tmpColor = new Color(0,0,0);  // Black
  282.             $tmpLineCap = new LineCap();
  283.             $this->outLine = new ChartPen($this->chart, $this->tmpColor, false,
  284.                                    $tmpLineCap->ROUND);
  285.         }
  286.         return $this->outLine;
  287.     }
  288.  
  289.         /**
  290.           * The vertical thickness of the line in pixels.<br>
  291.           * Default value: 0
  292.           *
  293.           * @return int 
  294.           */
  295.     public function getLineHeight() {
  296.         return $this->lineHeight;
  297.     }
  298.  
  299.         /**
  300.           * Sets the vertical thickness of the line in pixels.<br>
  301.           * Default value: 0
  302.           *
  303.           * @param value int
  304.           */
  305.     public function setLineHeight($value) {
  306.         $this->lineHeight = $this->setIntegerProperty($this->lineHeight, $value);
  307.     }
  308.  
  309.     public function calcHorizMargins($margins) {
  310.         parent::calcHorizMargins($margins);
  311.         $this->internalCalcMargin(!$this->getYMandatory(), true, $margins);
  312.     }
  313.  
  314.     private function internalCalcMargin($sameSide, $horizontal, $margins) {
  315.         if ($horizontal) {
  316.             $this->getPointer()->calcHorizMargins($margins);
  317.         } else {
  318.             $this->getPointer()->calcVerticalMargins($margins);
  319.         }
  320.  
  321.          $a = $margins->min;
  322.          $b = $margins->max;
  323.  
  324.         if ($this->drawLine) {
  325.             if ($this->stairs) {
  326.                 $a = max($a, $this->linePen->getWidth());
  327.                 $b = max($b, $this->linePen->getWidth() + 1);
  328.             }
  329.             if (($this->outLine != null) && ($this->outLine->getVisible())) {
  330.                 $a = max($a, $this->outLine->getWidth());
  331.                 $b = max($b, $this->outLine->getWidth());
  332.             }
  333.         }
  334.  
  335.         if ($this->marks!=null) {
  336.             if ($this->marks->getVisible() && $sameSide) {
  337.                 if ($this->yMandatory) {
  338.                     $a = max($a, $this->marks->getArrowLength());
  339.                 } else {
  340.                     $b = max($b, $this->marks->getArrowLength());
  341.                 }
  342.             }
  343.  
  344.             if ($this->marks->getVisible() && $sameSide) {
  345.                  $tmp = $this->marks->getCallout()->getLength() +
  346.                           $this->marks->getCallout()->getDistance();
  347.                 if ($this->yMandatory) {
  348.                     $a = max($b, $tmp);
  349.                 } else {
  350.                     $b = max($a, $tmp);
  351.                 }
  352.             }
  353.         }
  354.     }
  355.  
  356.     public function calcVerticalMargins($margins) {
  357.         parent::calcVerticalMargins($margins);
  358.  
  359.         $this->internalCalcMargin($this->yMandatory, false, $margins);
  360.  
  361.         if (($this->lineHeight > 0) && (!$this->drawArea) && $this->chart->getAspect()->getView3D()) {
  362.             if ($this->lineHeight > $margins->max) {
  363.                 $margins->max = $this->lineHeight;
  364.             }
  365.         }
  366.     }
  367.  
  368.     private function pointInVertLine($p, $x0, $y0, $y1) {
  369.         return MathUtils::pointInLineTolerance($p, $x0, $y0, $x0, $y1, 3);
  370.     }
  371.  
  372.     private function pointInHorizLine($p, $x0, $y0, $x1) {
  373.         return MathUtils::pointInLineTolerance($p, $x0, $y0, $x1, $y0, 3);
  374.     }
  375.  
  376.     private function checkPointInLine($p, $tmpX, $tmpY, $oldXPos, $oldYPos) {
  377.  
  378.         if ($this->chart->getAspect()->getView3D()) {
  379.             $tmp = array();
  380.             $tmp[0] = new TeePoint($tmpX, $tmpY);
  381.             $tmp[1] = new TeePoint($tmpX + $this->chart->getSeriesWidth3D(),
  382.                                     $tmpY - $this->chart->getSeriesHeight3D());
  383.             $tmp[2] = new TeePoint($oldXPos +  $this->chart->getSeriesWidth3D(),
  384.                                     $oldYPos - $this->chart->getSeriesHeight3D());
  385.             $tmp[3] = new TeePoint($oldXPos, $oldYPos);
  386.  
  387.             return GraphicsGD::pointInPolygon($p, $tmp);
  388.         } else
  389.         if ($this->stairs) {
  390.             if ($this->invertedStairs) {
  391.                 return $this->pointInVertLine($p, $oldXPos, $oldYPos, $tmpY) ||
  392.                         $this->pointInHorizLine($p, $oldXPos, $tmpY, $tmpX);
  393.             } else {
  394.                 return $this->pointInHorizLine($p, $oldXPos, $oldYPos, $tmpX) ||
  395.                         $this->pointInVertLine($p, $tmpX, $oldYPos, $tmpY);
  396.             }
  397.         } else {
  398.             return MathUtils::pointInLineTolerance($p, $tmpX, $tmpY,
  399.                                                   $oldXPos,
  400.                                                   $oldYPos, 3);
  401.         }
  402.     }
  403.  
  404.         /**
  405.           * Calculates if any point is at XY position.
  406.           *
  407.           * @param x int
  408.           * @param y int
  409.           * @return int Point index
  410.           */
  411.     public function clicked($x, $y) {
  412.  
  413.         if ($this->chart != null) {
  414.             $p = $this->chart->getGraphics3D()->calculate2DPosition($x, $y, $this->getStartZ());
  415.             $x = $p->x;
  416.             $y = $p->y;
  417.         }
  418.  
  419.          $result = parent::clicked($x, $y);
  420.  
  421.         if (($result == -1) &&
  422.             ($this->firstVisible > -1) && ($this->lastVisible > -1)) {
  423.              $oldXPos = 0;
  424.              $oldYPos = 0;
  425.              $previousBottomPos = 0;
  426.              $p = new TeePoint($x, $y);
  427.  
  428.             for ( $t = $this->firstVisible; $t <= $this->lastVisible; $t++) {
  429.  
  430.                  $tmpX = $this->calcXPos($t);
  431.                  $tmpY = $this->calcYPos($t);
  432.  
  433.                 if ($this->getPointer()->getVisible()) {
  434.                     if ($this->clickedPointer($t, $tmpX, $tmpY, $x, $y)) {
  435.                         $this->doClickPointer($t, $x, $y);
  436.                         return $t;
  437.                     }
  438.                 }
  439.                 if (($tmpX == $x) && ($tmpY == $y)) {
  440.                     return $t;
  441.                 }
  442.  
  443.                 if (($t > $this->firstVisible) && $this->bClickableLine) {
  444.  
  445.                     $tmp = Array();
  446.                     $tmp[0] = new TeePoint($oldXPos, $oldYPos);
  447.                     $tmp[1] = new TeePoint($tmpX, $tmpY);
  448.                     $tmp[2] = new TeePoint($tmpX, $this->getOriginPos($t));
  449.                     $tmp[3] = new TeePoint($oldXPos, $this->getOriginPos($t - 1));
  450.  
  451.                     if ($this->checkPointInLine($p, $tmpX, $tmpY, $oldXPos,
  452.                          $oldYPos) ||  ($this->drawArea &&
  453.                          $this->Graphics3D->pointInPolygon($p, $tmp))) {
  454.                         return $t - 1;
  455.                     }
  456.                 }
  457.  
  458.                 $oldXPos = $tmpX;
  459.                 $oldYPos = $tmpY;
  460.                 $previousBottomPos = $this->bottomPos;
  461.             }
  462.         }
  463.  
  464.         return $result;
  465.     }
  466.  
  467.     protected function draw() {
  468.  
  469.       if ($this->shadow->getVisible())
  470.           $tmpSize=$this->shadow->getSize();
  471.       else
  472.           $tmpSize=new Dimension(0,0);
  473.  
  474.  
  475.       if (($tmpSize->width!=0) || ( $tmpSize->height!=0))
  476.       {
  477.          $tmpColor=$this->getSeriesColor();
  478.          $this->setSeriesColor($this->shadow->getColor());
  479.  
  480.          $tmpPColor=$this->getPointer()->getVisible();
  481.          $this->getPointer()->setVisible(False);
  482.  
  483.          $this->getHorizAxis()->iStartPos+=$this->shadow->getHorizSize();
  484.          $this->getHorizAxis()->iEndPos+=$this->shadow->getHorizSize();
  485.          $this->getVertAxis()->iStartPos+=$this->shadow->getVertSize();
  486.          $this->getVertAxis()->iEndPos+=$this->shadow->getVertSize();
  487.  
  488.          parent::draw();
  489.  
  490.          $this->getHorizAxis()->iStartPos-=$this->shadow->getHorizSize();
  491.          $this->getHorizAxis()->iEndPos-=$this->shadow->getHorizSize();
  492.          $this->getVertAxis()->iStartPos-=$this->shadow->getVertSize();
  493.          $this->getVertAxis()->iEndPos-=$this->shadow->getVertSize();
  494.  
  495.          $this->getPointer()->setVisible($tmpPColor);
  496.          $this->setSeriesColor($tmpColor);
  497.       }
  498.  
  499.       if (($this->outLine != null) && ($this->outLine->getVisible())) {
  500.  
  501.           $previousColor = $this->getColor();
  502.           $this->setColor($this->outLine->getColor());
  503.           $oldWidth = $this->linePen->getWidth();
  504.           $oldPen = $this->linePen;
  505.           $this->linePen = $this->outLine;
  506.           $this->linePen->setWidth($oldWidth + $this->outLine->getWidth() + 2);
  507.           parent::draw();
  508.           $this->linePen->setWidth($oldWidth);
  509.           $this->linePen = $oldPen;
  510.           $this->setColor($previousColor);
  511.       }
  512.       parent::draw();
  513.     }
  514.  
  515.         /* calculate vertical pixel */
  516.     private function calcYPosLeftRight($yLimit, $anotherIndex, $valueIndex) {
  517.  
  518.          $tmpPredValueX = $this->vxValues->value[$anotherIndex];
  519.          $tmpDif = $this->vxValues->value[$valueIndex] - $tmpPredValueX;
  520.         if ($tmpDif == 0) {
  521.             return $this->calcYPos($anotherIndex);
  522.         } else {
  523.              $tmpPredValueY = $this->vyValues->value[$anotherIndex];
  524.             return $this->getVertAxis()->calcYPosValue(1.0 * $tmpPredValueY +
  525.                                                ($this->yLimit - $tmpPredValueX) *
  526.                                                ($this->vyValues->value[$valueIndex] -
  527.                                                 $tmpPredValueY) / $tmpDif);
  528.         }
  529.     }
  530.  
  531. //    private Rectangle RectFromPoints(int P0X,int P0Y,int P1X,int P1Y,int P2X,int P2Y,int P3X,int P3Y)
  532. //    {
  533. //      Rectangle r=new Rectangle();
  534. //      r.x=Math.min(P3X,Math.min(P2X,Math.min(P0X,P1X)));
  535. //      r.y=Math.min(P3Y,Math.min(P2Y,Math.min(P0Y,P1Y)));
  536. //      r.width=Math.max(P3X,Math.max(P2X,Math.max(P0X,P1X)))-r.x;
  537. //      r.height=Math.max(P3Y,Math.max(P2Y,Math.max(P0Y,P1Y)))-r.y;
  538. //      return chart.getAspect().getView3D() ? chart.getGraphics3D().CalcRect3D(r,getStartZ()) : r;
  539. //    }
  540.  
  541.     protected function getAreaBrushColor($c) {
  542.         if ($this->bColorEach) {
  543.             return $c;
  544.         } else
  545.         if ($this->bAreaBrush == null) {
  546.             return $c;
  547.         } else {
  548.             return $this->bAreaBrush->getColor()->isEmpty() ? $c : $this->bAreaBrush->getColor();
  549.         }
  550.     }
  551.  
  552.     private function drawArea($brushColor, $x, $y) {    
  553.         $g = $this->chart->getGraphics3D();
  554.  
  555.         if (!$this->bAreaBrush->getColor()->isEmpty()) {
  556.             $this->bAreaBrush->setTransparency($this->getTransparency());
  557.         }
  558.  
  559.         $this->chart->setBrushCanvas($brushColor, $this->bAreaBrush,
  560.                              $this->bAreaBrush->getColor()->isEmpty() ? $this->getColor() :
  561.                              $this->bAreaBrush->getColor());
  562.  
  563.         if ($this->chart->getAspect()->getView3D() && $this->isLastValue) { // final point
  564.             if ($this->yMandatory) {
  565.                 $g->rectangleZ($x, $y, $this->bottomPos, $this->getStartZ(), $this->getEndZ());
  566.             } else {
  567.                 $g->rectangleY($x, $y, $this->bottomPos, $this->getStartZ(), $this->getEndZ());
  568.             }
  569.         }
  570.  
  571.         if ($this->stairs) {
  572.             if ($this->invertedStairs) {
  573.                 $tmpY = $this->yMandatory ? $y : $x;
  574.                 $tmpBottom = $this->bottomPos;
  575.             } else {
  576.                 $tmpY = $this->yMandatory ? $this->oldY : $this->oldX;
  577.                 $tmpBottom = $this->oldBottomPos;
  578.             }
  579.  
  580.             if ($this->yMandatory) {
  581.                 $tmpR = new Rectangle($this->oldX, $tmpY, $x - $this->oldX,
  582.                                      $tmpBottom - $tmpY);
  583.             } else {
  584.                 $tmpR = new Rectangle($tmpBottom, $y, $tmpY - $tmpBottom - 1,
  585.                                      $this->oldY - $y);
  586.             }
  587.  
  588.             if ($this->chart->getAspect()->getView3D()) {
  589.                 $g->rectangle($tmpR, $this->getStartZ());
  590.                 if ($g->getSupportsFullRotation()) {
  591.                     $g->rectangle($tmpR, $this->getEndZ());
  592.                 }
  593.             }
  594.             else {
  595.                 $g->rectangle($tmpR);
  596.             }
  597.         } else {
  598.             // not in "stairs" mode...
  599.             if ($this->yMandatory) {
  600.                 $tmp0 = new TeePoint($this->oldX, $this->oldBottomPos);
  601.                 $tmp3 = new TeePoint($x, $this->bottomPos);
  602.             } else {
  603.                 $tmp0 = new TeePoint($this->oldBottomPos, $this->oldY);
  604.                 $tmp3 = new TeePoint($this->bottomPos, $y);
  605.             }
  606.  
  607.             $tmp1 = new TeePoint($this->oldX, $this->oldY);
  608.             $tmp2 = new TeePoint($x, $y);
  609.  
  610.             if ($this->chart->getAspect()->getView3D()) {
  611.                 $g->_plane($tmp0, $tmp1, $tmp2, $tmp3, $this->startZ);
  612.             } else
  613.             if (($this->getBrush() != null) && ($this->getBrush()->getGradientVisible())) {
  614.                 $tmp = Array();
  615.                 $tmp[0] = $tmp0;
  616.                 $tmp[1] = $tmp1;
  617.                 $tmp[2] = $tmp2;
  618.                 $tmp[3] = $tmp3;
  619.  
  620.                 $g->clipPolygon($tmp);
  621.  
  622.                 $tmpMax = $this->calcPosValue($this->mandatory->getMaximum());
  623.                 $tmpMin = $this->calcPosValue($this->mandatory->getMinimum());
  624.  
  625.                 if ($this->yMandatory) {
  626.                     $tmpR = new Rectangle($this->oldX, $tmpMax, $x, $tmpMin);
  627.                 } else {
  628.                     $tmpR = new Rectangle($tmpMin, $this->oldY, $tmpMax, $y);
  629.                 }
  630.  
  631.                 $this->getBrush()->getGradient()->draw($g, $tmpR);
  632.                 $g->unClip();
  633.  
  634.                 $this->getBrush()->setVisible(false);
  635.                 if ($this->pAreaLines->getVisible()) {
  636.                     if ($this->yMandatory) {
  637.                         $g->verticalLine($this->oldX, $this->oldY, $this->oldBottomPos);
  638.                     } else {
  639.                         $g->horizontalLine($this->oldBottomPos, $this->oldX, $this->oldY);
  640.                     }
  641.                 }
  642.  
  643.             } else {
  644.                 $tmp = Array();
  645.                 $tmp[0] = $tmp0;
  646.                 $tmp[1] = $tmp1;
  647.                 $tmp[2] = $tmp2;
  648.                 $tmp[3] = $tmp3;
  649.                 $g->polygon($tmp);
  650.             }
  651.  
  652.             if ($g->getSupportsFullRotation()) {
  653.                 $g->plane($tmp0, $tmp1, $tmp2, $tmp3, $this->getEndZ());
  654.             }
  655.  
  656.             if ($this->linePen->getVisible()) {
  657.                 $g->setPen($this->getLinePen());
  658.                 $g->_line($this->oldX, $this->oldY, $x, $y, $this->getStartZ());
  659.             }
  660.         }
  661.     }
  662.  
  663.     private function drawPoint($drawOldPointer, $valueIndex, $x, $y) {
  664.       
  665.         $p4 = Array();
  666.         $p4[] = new TeePoint;
  667.         $g = $this->chart->getGraphics3D();
  668.  
  669.         if ((($x != $this->oldX) || ($y != $this->oldY)) && (!$this->tmpColor->isEmpty())) { // <-- if !null
  670.             if ($this->chart->getAspect()->getView3D()) {
  671.                 // 3D
  672.                 if ($this->drawArea || $this->drawLine) {
  673.                     $g->setPen($this->getLinePen());
  674.                     if ($this->tmpColor->isNull()) {
  675.                         $g->getPen()->setColor($this->tmpColor);
  676.                     }
  677.  
  678.                     //if ( linePen.getVisible() ) CheckPenWidth(g.Pen);
  679.  
  680.                     $g->setBrush($this->getBrush());
  681.  
  682.                     if ($this->colorEachLine || $this->drawArea) {
  683.                         $oldDarkColor = $this->getAreaBrushColor($this->tmpColor);
  684.                     } else {
  685.                         $oldDarkColor = $this->getColor(); // 6.01
  686.                     }
  687.  
  688.                     //OldDarkColor=GetAreaBrushColor(tmpColor);
  689.  
  690.                     $oldBrushColor = $g->getBrush()->getColor();
  691.                     $g->getBrush()->setColor($oldDarkColor);
  692.  
  693.                     //                        if (transparency>0) {
  694.                     //                            OldDarkColor=Color.FromArgb((100-transparency)*255/100,OldDarkColor);
  695.                     //                            g.SetTransparency(transparency);
  696.                     //                        }
  697.  
  698.                     //if ( g.getBrush().Image != null )
  699.                     //  g.getBrush().Bitmap=Brush.Image.Bitmap;
  700.  
  701.                      $tmpPoint = new TeePoint($x, $y);
  702.                      $tmpOldP = new TeePoint($this->oldX, $this->oldY);
  703.  
  704.                     if ($this->stairs) {
  705.                         if ($this->invertedStairs) {
  706.                             /* || LastValue=FirstValueIndex */
  707.                             if ($this->bDark3D) {
  708.                                 $g->getBrush()->applyDark(GraphicsGD::$DARKCOLORQUANTITY);
  709.                             }
  710.                             $g->rectangleZ($tmpOldP->x, $tmpOldP->y, $y,
  711.                                          $this->getStartZ(),
  712.                                          $this->getEndZ());
  713.                             if ($this->bDark3D) {
  714.                                 $g->getBrush()->setColor($oldDarkColor);
  715.                             }
  716.                             $g->rectangleY($tmpPoint->x, $tmpPoint->y, $this->oldX,
  717.                                          $this->getStartZ(), $this->getEndZ());
  718.                         } else {
  719.                             $g->rectangleY($tmpOldP->x, $tmpOldP->y, $x,
  720.                                          $this->getStartZ(),
  721.                                          $this->getEndZ());
  722.                             if ($this->bDark3D) {
  723.                                 $g->getBrush()->applyDark(GraphicsGD::$DARKCOLORQUANTITY);
  724.                             }
  725.                             $g->rectangleZ($tmpPoint->x, $tmpPoint->y, $this->oldY,
  726.                                          $this->getStartZ(), $this->getEndZ());
  727.                             if ($this->bDark3D) {
  728.                                 $g->getBrush()->setColor($oldDarkColor);
  729.                             }
  730.                         }
  731.                     } else {
  732.                         if (($this->lineHeight > 0) && (!$this->drawArea)) {
  733.                             $p4[0] = $tmpPoint;
  734.                             $p4[1] = $tmpOldP;
  735.                             $p4[2] = new TeePoint($tmpOldP);
  736.                             $p4[2]->y += $this->lineHeight;
  737.                             $p4[3] = new TeePoint($tmpPoint);
  738.                             $p4[3]->y += $this->lineHeight;
  739.  
  740.                             $g->planeFour3D($this->getStartZ(), $this->getStartZ(), $p4);
  741.  
  742.                             if ($this->isLastValue) {
  743.                                 $g->rectangleZ($tmpPoint->x, $tmpPoint->y,
  744.                                              $tmpPoint->y + $this->lineHeight,
  745.                                              $this->getStartZ(), $this->getEndZ());
  746.                             }
  747.                         }
  748.  
  749.                          $tmpDark3D = $this->bDark3D && (!$g->getSupportsFullRotation());
  750.                         if ($tmpDark3D) {
  751.  
  752.                              $tmpDifX = $tmpPoint->getX() - $tmpOldP->getX();
  753.  
  754.                             if (($tmpDifX != 0) && ($this->tmpDark3DRatio != 0) &&
  755.                                 (($tmpOldP->getY() - $tmpPoint->getY()) / $tmpDifX >
  756.                                  $this->tmpDark3DRatio)) {
  757.                                 $g->getBrush()->applyDark(GraphicsGD::$DARKCOLORQUANTITY);
  758.                                 if (($this->lineHeight > 0) && (!$this->drawArea)) {
  759.                                     /*special case*/
  760.                                     $tmpPoint->setY($tmpOldP->getY() + $this->lineHeight);
  761.                                     $tmpOldP->setY($tmpOldP->getY() + $this->lineHeight);
  762.                                 }
  763.                             }
  764.                         }
  765.                         if ($g->getMonochrome()) {
  766.                             $this->tmpColor = new Color(255,255,255);  // White
  767.                             $g->getBrush()->setColor($this->tmpColor);
  768.                         }
  769.  
  770.  
  771.                         $g->plane($tmpPoint, $tmpOldP, $this->getStartZ(), $this->getEndZ());
  772.  
  773.                         if ($tmpDark3D) {
  774.                             $g->getBrush()->setColor($oldDarkColor);
  775.                         }
  776.                     }
  777.                     $g->getBrush()->setColor($oldBrushColor);
  778.                 }
  779.             }
  780.         }
  781.  
  782.         if ($this->drawArea) {
  783.             //Color oldColor=g.getBrush().Color;
  784.             $g->getBrush()->setColor($this->getAreaBrushColor($this->tmpColor));
  785.  
  786.             $g->setPen($this->pAreaLines);
  787.  
  788.             if ($this->pAreaLines->getColor()->isEmpty() || (!$this->pAreaLines->getVisible())) {
  789.                 $g->getPen()->setColor($this->tmpColor);
  790.             } else {
  791.                 $g->setPen($this->pAreaLines);
  792.             }
  793.  
  794.             $this->drawArea($g->getBrush()->getColor(), $x, $y);
  795.             //g.getBrush().Color=oldColor;
  796.         } else
  797.         if ((!$this->chart->getAspect()->getView3D()) && $this->drawLine) {
  798.  
  799.             // line 2D
  800.             $this->linePrepareCanvas($g, $this->colorEachLine ? $this->tmpColor : $this->getColor());
  801.  
  802.             if ($this->stairs) {
  803.                 if ($this->invertedStairs) {
  804.                     $g->verticalLine($this->oldX, $this->oldY, $y);
  805.                 } else {
  806.                     $g->horizontalLine($this->oldX, $x, $this->oldY);
  807.                 }
  808.                 $g->moveToXY($x,$this->oldY);
  809.                 $g->_____lineTo($x, $y);        
  810. //                $g->___lineTo($this->oldX, $this->oldY, 0);                
  811.             } else {
  812.                 $g->line($this->oldX, $this->oldY, $x, $y);
  813.             }
  814.         }
  815.  
  816.         /* pointers */
  817.         if ($this->point->getVisible() && $drawOldPointer) {
  818.             if (!$this->oldColor->isEmpty()) /* <-- if ( !null */
  819.             {
  820.                 $this->drawPointer($this->oldX, $this->oldY, $this->oldColor, $valueIndex - 1);
  821.             }
  822.             if ($this->isLastValue && (!$this->tmpColor->isEmpty())) /*<-- if ( !null */
  823.             {
  824.                 $this->drawPointer($x, $y, $this->tmpColor, $valueIndex);
  825.             }
  826.         }
  827.     }
  828.  
  829.         /**
  830.           * Called internally. Draws the "ValueIndex" point of the Series.
  831.           *
  832.           * @param valueIndex int
  833.           */
  834.     public function drawValue($valueIndex) {
  835.        
  836.         $g = $this->chart->getGraphics3D();
  837.  
  838.         $this->tmpColor = $this->getValueColor($valueIndex);
  839.         $x = $this->calcXPos($valueIndex);
  840.         $y = $this->calcYPos($valueIndex);
  841.  
  842.         $g->getPen()->setColor(new Color(0,0,0));
  843.         $g->getBrush()->setColor($this->tmpColor);
  844.  
  845.         if ($this->oldColor->isEmpty()) { // if null
  846.             $this->oldX = $x;
  847.             $this->oldY = $y;
  848.         }
  849.  
  850.         $this->bottomPos = $this->getOriginPos($valueIndex);
  851.  
  852.         if ($this->drawValuesForward()) {
  853.             $tmpFirst = $this->firstVisible;
  854.             $this->isLastValue = ($valueIndex == $this->lastVisible);
  855.         } else {
  856.             $tmpFirst = $this->lastVisible;
  857.             $this->isLastValue = ($valueIndex == $this->firstVisible);
  858.         }
  859.  
  860.         if ($valueIndex == $tmpFirst) {
  861.             // first point
  862.             if ($this->bDark3D) {
  863.                 if ($this->chart->getSeriesWidth3D() != 0) {
  864.                     $this->tmpDark3DRatio = $this->chart->getSeriesHeight3D() / $this->chart->getSeriesWidth3D();
  865.                 } else {
  866.                     $this->tmpDark3DRatio = 1;
  867.                 }
  868.             }
  869.  
  870.             if (($tmpFirst == $this->firstVisible) && ($valueIndex > 0)) {
  871.                 // previous point outside left
  872.                 if ($this->drawArea) {
  873.                     $this->oldX = $this->calcXPos($valueIndex - 1);
  874.                     $this->oldY = $this->calcYPos($valueIndex - 1);
  875.                     $this->oldBottomPos = $this->getOriginPos($valueIndex - 1);
  876.                 } else {
  877.                     $tmpRect = $this->chart->getChartRect();
  878.                     $this->oldX = $this->getHorizAxis()->getInverted() ? $tmpRect->getRight() :
  879.                            $tmpRect->x;
  880.  
  881.                     if ($this->stairs) {
  882.                         $this->oldY = $this->calcYPos($valueIndex - 1);
  883.                     } else {
  884.                         $this->oldY = $this->calcYPosLeftRight($this->xScreenToValue($this->oldX),
  885.                                                  $valueIndex - 1, $valueIndex);
  886.                     }
  887.                 }
  888.                 if (!$this->isNull($valueIndex - 1)) {
  889.                     $this->drawPoint(false, $valueIndex, $x, $y);
  890.                 }
  891.             }
  892.  
  893.             if ($this->isLastValue && $this->point->getVisible()) {
  894.                 $this->drawPointer($x, $y, $this->tmpColor, $valueIndex);
  895.             }
  896.  
  897.             if ($g->getSupportsFullRotation() && $this->drawArea &&
  898.                 $this->chart->getAspect()->getView3D()) {
  899.                 $g->rectangleZ($x, $y, $this->bottomPos, $this->getStartZ(), $this->getEndZ());
  900.             }
  901.         } else {
  902.             if (!$this->isNull($valueIndex - 1)) {
  903.                 $this->drawPoint(true, $valueIndex, $x, $y);
  904.             }
  905.         }
  906.  
  907.         $this->oldX = $x;
  908.         $this->oldY = $y;
  909.         $this->oldBottomPos = $this->bottomPos;
  910.         $this->oldColor = $this->tmpColor;
  911.     }
  912.  
  913.     private function drawLine($g, $drawRectangle, $tmpColor, $rect) {
  914.         
  915.         if ($this->chart->getLegend()->getSymbol()->getDefaultPen()) {
  916.             $this->linePrepareCanvas($g, $tmpColor);
  917.         }
  918.  
  919.         if ($drawRectangle) {
  920.             $g->rectangle($rect);
  921.         } else {
  922.             $g->horizontalLine($rect->x, $rect->getRight(),
  923.                              ($rect->y + $rect->getBottom()) / 2,0);
  924.         }
  925.     }
  926.  
  927.     protected function drawLegendShape($g, $valueIndex, $rect) {
  928.         
  929.         $tmpLegendColor = ($valueIndex == -1) ? $this->getColor() :
  930.                          $this->getValueColor($valueIndex);
  931.                          
  932.         if ($this->getPointer()->getVisible()) {
  933.             if ($this->drawLine) {
  934.                 $this->drawLine($g, false, $tmpLegendColor, $rect);
  935.             }
  936.             $this->point->drawLegendShape($g, $tmpLegendColor, $rect, $this->getLinePen()->getVisible());
  937.         } else
  938.         if ($this->drawLine && (!$this->drawArea)) {
  939.             $this->drawLine($g, $this->chart->getAspect()->getView3D(), $tmpLegendColor, $rect);
  940.         } else {
  941.             parent::drawLegendShape($g, $valueIndex, $rect);
  942.         }
  943.     }
  944.  
  945.     private function linePrepareCanvas($g, $aColor) {
  946.         if ($g->getMonochrome()) {
  947.             $aColor = new Color(255,255,255);  // White
  948.         }
  949.         if ($this->chart->getAspect()->getView3D()) {
  950.             $g->setBrush($this->getBrush());
  951.  
  952.             if ($this->bBrush->getImage() != null) {
  953.                 $g->getBrush()->setImage($this->bBrush->getImage());
  954.             } else {
  955.                 $g->getBrush()->setStyle($this->bBrush->getStyle());
  956.                 $g->getBrush()->setColor($aColor);
  957.             }
  958.             $g->setPen($this->getLinePen());
  959.             if ($aColor->isNull()) {
  960.                 $g->getPen()->setColor($aColor);
  961.             }
  962.         } else {
  963.             $g->getBrush()->setVisible(false);
  964.             $g->setPen($this->getLinePen());
  965.             $g->getPen()->setColor($aColor);
  966.         }
  967.         // chart.CheckPenWidth(g.Pen);
  968.     }
  969.  
  970.     public function getShadow() {
  971.        return $this->shadow;
  972.     }
  973.  
  974.     public function setShadow($value) {
  975.        $this->shadow->assign($value);
  976.     }
  977. }
  978.  
  979. ?>

Documentation generated on Wed, 16 Jun 2010 12:04:45 +0200 by phpDocumentor 1.4.1